package com.hrt.datasender.web.bcplcpointconfig;

import com.btcode.web.core.annotation.RequestMapping;
import com.btcode.web.core.controller.Controller;
import com.hrt.common.web.DSRequestUnit;
import com.hrt.datasender.datadao.model.BcParamMap212Model;
import com.hrt.datasender.web.bcparammap212.BcParamMap212Service;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * PLC点位配置
 */
@RequestMapping(path = "bc-plc-point-config")
public class BcPlcPointConfigController extends Controller {

    @RequestMapping(path = "create")
    public void create(ServletRequest arg0, ServletResponse arg1) throws IOException {

        BcPlcPointConfigModel model = DSRequestUnit.getModel(BcPlcPointConfigModel.class);
        BcPlcPointConfigService.getInstance().create(model);
        success(model);
    }

    @RequestMapping(path = "update")
    public void update(ServletRequest arg0, ServletResponse arg1) throws IOException {

        BcPlcPointConfigModel model = DSRequestUnit.getModel(BcPlcPointConfigModel.class);
        BcPlcPointConfigService.getInstance().update(model);
        success(model);
    }

    @RequestMapping(path = "delete")
    public void delete(ServletRequest arg0, ServletResponse arg1) throws IOException {

        String id = DSRequestUnit.getString("id");
        BcPlcPointConfigService.getInstance().delete(id);
        success("");
    }

    @RequestMapping(path = "getList")
    public void getList(ServletRequest arg0, ServletResponse arg1) throws IOException {
        List<BcPlcPointConfigModel> models = BcPlcPointConfigService.getInstance().getList();
        success(models);
    }

}
